﻿@model eBusiness.Models.Category

@{
    ViewBag.Title = "Delete";
    Layout = "../Shared/_Layout.cshtml";
}

<h2>Delete</h2>

<h3>Are you sure you want to delete this?</h3>
<fieldset>
    <legend>Category</legend>

    <table class="dashboardTable">
        <tr>
            <td style="width: 200px; padding: 10px;">
                <img width="200px" src="@Model.Icon" alt="icon"/>
            </td>
            <td>
                <table class="dashboardTable">
                    <tr>
                        <td class="display-field" colspan="2">
                            <h3>@Html.DisplayFor(model => model.Name)</h3>
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            Description
                        </td>
                        <td class="display-field">
                            @Html.DisplayFor(model => model.Description)
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            CreatedBy
                        </td>
                        <td class="display-field">
                            @{
                                if (!string.IsNullOrEmpty(Model.CreatedBy.ToString()))
                                {
                                    var membershipUser = Membership.GetUser(Model.CreatedBy);
                                    if (membershipUser != null)
                                    {
                                        var usr = membershipUser.UserName;
                                        @usr
                                    }
                                }
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            CreatedDate
                        </td>
                        <td class="display-field">
                            @if (!string.IsNullOrEmpty(@Model.CreatedDate.ToString()))
                            {
                                @Model.CreatedDate.ToString("dd/MM/yyyy")
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            ModifiedBy
                        </td>
                        <td class="display-field">
                            @{
                                if (!string.IsNullOrEmpty(Model.CreatedBy.ToString()))
                                {
                                    var membershipUser = Membership.GetUser(Model.CreatedBy);
                                    if (membershipUser != null)
                                    {
                                        var usr = membershipUser.UserName;
                                        @usr
                                    }
                                }
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            ModifiedDate
                        </td>
                        <td class="display-field">
                            @if (!string.IsNullOrEmpty(@Model.ModifiedDate.ToString()))
                            {
                                @Model.ModifiedDate.Value.ToString("dd/MM/yyyy")
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="display-label">
                            IsMenu
                        </td>
                        <td class="display-field">
                            @Html.DisplayFor(model => model.IsMenu)
                            @if (@Model.IsMenu && (!string.IsNullOrEmpty(Model.IsMenuStartDate.ToString()) || !string.IsNullOrEmpty(Model.IsMenuEndDate.ToString())))
                            {
                                <div>
                                    <span class="leftDetailsTableColumn">From </span>
                                    @if (string.IsNullOrEmpty(Model.IsMenuStartDate.ToString()))
                                    {
                                        <span>n/a</span>
                                    }
                                    else
                                    {
                                        @Model.IsMenuStartDate.Value.ToString("dd/MM/yyyy");
                                    }
                                    <span class="leftDetailsTableColumn">To </span>
                                    @if (string.IsNullOrEmpty(Model.IsMenuEndDate.ToString()))
                                    {
                                        <span>n/a</span>
                                    }
                                    else
                                    {
                                        @Model.IsMenuEndDate.Value.ToString("dd/MM/yyyy");
                                    }
                                </div>
                            }
                        </td>
                    </tr>
                    @if (@Model.Parent != null)
                    {
                        <tr>
                            <td>
                                Parent
                            </td>
                            <td>
                                <a href="@Url.Action("Details", "Categories", new {id = Model.ParentID})">@Model.Parent.Name</a>
                            </td>
                        </tr>
                    }
                    @if (@Model.Childs.Count > 0)
                    {
                        <tr>
                            <td>
                                Children
                            </td>
                            <td>
                                @foreach (var item in @Model.Childs)
                                {
                                     if (item != null)
                                      {
                                          <div>
                                              <a href="@Url.Action("Details", "Categories", new {id = Model.ParentID})">@item.Name</a>
                                          </div>
                                      }
                                }
                            </td>
                        </tr>   
                    }
                </table>
            </td>
        </tr>
    </table>
</fieldset>
@using (Html.BeginForm()) {
    <p>
        <input type="submit" value="Delete" /> |
        @Html.ActionLink("Back to List", "Index")
    </p>
}
